package com.njsf.controller.back;

import com.github.pagehelper.PageInfo;
import com.njsf.dto.ResponseJson;
import com.njsf.pojo.Admin;
import com.njsf.service.AdminService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
<<<<<<< HEAD
import org.springframework.web.servlet.ModelAndView;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.List;
=======

import javax.servlet.http.HttpServletRequest;
>>>>>>> 180ace60693232df69575b4f82fc34aeb3fc90e8
import java.util.Map;

@Controller
@RequestMapping("/back")
public class AdminCotroller {

    @Autowired
    private AdminService adminService;

    @RequestMapping("/checklogin")
    @ResponseBody
    public ResponseJson login(String adminName, String password,HttpServletRequest request){
        return adminService.checkLogin(adminName,password,request);
    }

    @RequestMapping("/adminlist")
    public String adminList(@RequestParam(required = false,defaultValue = "1") Integer start,
                            @RequestParam(required = false,defaultValue = "5") Integer pageSize,
                            Map<String,Object> map){
        PageInfo<Admin> pageInfo = adminService.getAdmins(start,pageSize);
        map.put("pageInfo",pageInfo);
        return "back/admin/admin-list";
    }

    @RequestMapping("/deladmin")
    @ResponseBody
    public ResponseJson delAdmin(Integer id){
        return adminService.delAdmin(id);
    }

    @RequestMapping("/addView")
    public String addView(){
        return "back/admin/admin-add";
    }
<<<<<<< HEAD
=======

    /*修改用户界面*/
    @RequestMapping("/editadminview")
    public String editadminview(Map<String, Object> map,Integer id){
        map.put("oneAdmin",adminService.getOneAdmin(id));
        return "back/admin/admin-edit";
    }

    @RequestMapping("/editedadmin")
    @ResponseBody
    public ResponseJson saveEditAdmin(Admin admin){
        System.out.println(admin);
        return adminService.updateAdmin(admin);
    }

>>>>>>> 180ace60693232df69575b4f82fc34aeb3fc90e8
}
